package com.slwish.xty.ui.activity;

import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.slwish.common.base.PresenterToolbarActivity;
import com.slwish.xty.R;
import com.slwish.xty.mvp.contract.RealNameAuthentContract;
import com.slwish.xty.mvp.presenter.RealNameAuthentPresenter;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 实名认证
 */
public class RealNameAuthentActivity extends PresenterToolbarActivity<RealNameAuthentContract.Presenter> implements RealNameAuthentContract.View {
    @BindView(R.id.et_username)
    EditText mEtUserName;
    @BindView(R.id.et_idcard)
    EditText mEtIdCard;
    @BindView(R.id.btn_login)
    TextView btnLogin;

    @Override
    protected int getLayoutId() {
        return R.layout.act_real_name_authent;
    }

    @Override
    protected void initWidget() {
        super.initWidget();
        setTitle(R.string.user_info_smrz_text);
        mEtIdCard.addTextChangedListener(textWatcher);
        mEtUserName.addTextChangedListener(textWatcher);
    }

    //输入框监听
    TextWatcher textWatcher = new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before,
                                  int count) {
            if (TextUtils.isEmpty(mEtUserName.getText()) || TextUtils.isEmpty(mEtIdCard.getText())) {
                btnLogin
                        .setBackgroundResource(R.drawable.btn_unable_selector);
                btnLogin.setEnabled(false);
            } else {
                btnLogin
                        .setBackgroundResource(R.drawable.btn_select_selector);
                btnLogin.setEnabled(true);
            }
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count,
                                      int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {

        }
    };

    @Override
    protected RealNameAuthentContract.Presenter initPresenter() {
        return new RealNameAuthentPresenter(this);
    }

    /**
     *
     * @param view
     */
    @OnClick({R.id.ll_call_kf, R.id.btn_login})
    public void setOnClick(View view) {
        switch (view.getId()) {
            case R.id.ll_call_kf:
                break;
            case R.id.btn_login:
//                mPresenter.newMobile(mContext,mEtPhone.getText().toString(), mEtYzm.getText().toString());
                break;
        }

    }
}
